﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<Info>>" %>
<%@ Import Namespace="Ornament.Messages" %>

<script src="../../Scripts/jquery.endless-scroll.js" type="text/javascript"></script>

<style type="text/css">
    ul.announce
    {
        width: 100%;
        height: 400px;
        font-size: 14px;
        margin-left: 6px;
        overflow: auto;
        padding-right:8px;
    }
    .announce li
    {
        border: 1px solid #CCCCCC;
        margin-bottom: 10px;
        -moz-border-radius: 4px 4px 4px 4px;        
    }
    .announce li .content
    {
        padding-bottom: 5px;
    }
    .announce .ui-icon
    {
        float: right;
        cursor: pointer;
    }
    .announce .mainContent
    {
        clear: both;
        padding: 0 0 5px 10px;
    }
    .announce .toolbar
    {
        padding: 0 10px;
    }
</style>

<script type="text/javascript">
    var workListIndex = 0;
    var workListIsEmpty = false;
    $(document).ready(function() {
        // auto scroll work list;
        $(".announce").endlessScroll({
            fireOnce: true,
            fireDelay: false,
            loader: "<div class=\"loading\"><div>",
            callback: function() {
                if (!workListIsEmpty) {
                    $.post('<%=Url.Action("ListWorks","Messages")%>', { pageIndex: workListIndex, pageSize: 10, template: "work" }, function(data) {
                        workListIsEmpty = data.length == 0;
                        for (var idx = 0; idx < data.length; idx++) {
                            var item = $(data[idx]);
                            var container = $('<li><span class="ui-icon ui-icon-circle-close" title="关闭,下次会再次显示"></span></li>')
                            .append(
                                $('<div class="mainContent"></div>')
                                .append(item)
                            );
                            $(".announce").append(container);
                        }
                        workListIndex++;
                    });
                }
            }
        });

        $(".close").live('click', function() {
            var id = $(this).attr("id");
            var t = $(this);
            $.post('<%=Url.Action("ReadIt","Messages")%>', { id: id }, function(data) {
                if (data.Success) {
                    t.closest("li").fadeOut();
                }
            });
            return false;
        });
    });
</script>

<div class="panel" style="padding-right: 5px;">
    <ul class="announce">
        <%
            foreach (var s in this.Model)
            {
        %>
        <li><span class="ui-icon ui-icon-circle-close close" title="关闭,下次会再次显示"></span>
            <div class="mainContent">
                <%=s.Show("work")%>
            </div>
        </li>
        <%
            }
        %>
    </ul>
</div>
